﻿// <com.woyouqiu.Copyright>
// --------------------------------------------------------------
// <copyright>上海有求网络科技有限公司 2015</copyright>
// <Solution>Vecen.BangChuang</Solution>
// <Project>Vecen.BangChuang.Application</Project>
// <FileName>CommonAppService.cs</FileName>
// <CreateTime>2017-04-27 21:39</CreateTime>
// <Author>何苗</Author>
// <Email>hemiao@woyouqiu.com</Email>
// <log date="2017-04-27 21:39" version="00001">创建</log>
// --------------------------------------------------------------
// </com.woyouqiu.Copyright>

using System.Threading.Tasks;
using Abp;
using Abp.Authorization;
using Abp.Runtime.Session;

namespace Vecen.BangChuang.BangChuang.Common {
    /// <summary>
    /// 设置功能操作
    /// </summary>
    [AbpAuthorize()]
    public class SettingAppService: BangChuangAppServiceBase, ISettingAppService {
        /// <summary>
        /// 设置是否显式成本价
        /// </summary>
        /// <param name="isDisplay"></param>
        /// <returns></returns>
        public async Task SetDisplayCostAsync(bool isDisplay) {
            await SettingManager.ChangeSettingForUserAsync(AbpSession.ToUserIdentifier(),
                BangChuangConsts.SettingsName.DisplayCostPriceForApp, isDisplay.ToString());
        }

        /// <summary>
        /// 设置是否在分享界面上显式价格
        /// </summary>
        /// <param name="isDisplay"></param>
        /// <returns></returns>
        public async Task SetDisplayPriceOnShareAsync(bool isDisplay) {
            await SettingManager.ChangeSettingForUserAsync(AbpSession.ToUserIdentifier(),
                BangChuangConsts.SettingsName.DisplayPriceOnSharePage, isDisplay.ToString());
        }

        /// <summary>
        /// 获得欢迎页背景图片
        /// </summary>
        /// <returns></returns>
        [AbpAllowAnonymous]
        public Task<int?> GetWelcomeBgAsync() {
            return AttachmentManager.GetIdAsync(BangChuangConsts.AppWelcomeBgImageAttachmentType, null);
        }
    }
}